import { request } from 'umi';
// @ts-ignore
import Cookies from 'js-cookie';

/** 登录 */
export async function login(body: USERAPI.LoginParams) {
  return request(`/api/bui/load`, {
    method: 'GET',
    params: body
  });
}

/** 获取当前的用户 */
export async function currentUser() {
  return request<USERAPI.CurrentUser>('/api/bui/oper/info', {
    method: 'GET'
  });
}

/** 获取当前的用户的可用按钮 */
export async function getCurrentUserActionList() {
  return request('/api/bui/action/of/oper', {
    method: 'GET'
  });
}

/** 获取当前的用户的菜单 */
export async function getCurrentUserMenus() {
  return request<USERAPI.UserMenu[]>('/api/bui/menu/of/oper', {
    method: 'GET'
  });
}

// 任意门超级管理员切换账号
export async function changeOper(data: any) {
  return request(`/api/bui/super/oper/charge`, {
    method: 'PATCH',
    data
  });
}

// 查询当前账号业务科室列表
export async function getCurrentUserDept() {
  return request('/api/bui/oper/dept/1/limit/9999');
}

// 设置默认业务科室
export async function setApprove(data: any) {
  return request(`/api/bui/oper/${data.oper_id}/approve`, {
    method: 'PATCH',
    data
  });
}

// 更换当前账号业务科室信息
export async function chargeByOperId(data: any) {
  return request(`/api/bui/oper/${data.oper_id}/charge`, {
    method: 'PATCH',
    data
  });
}


// 二级部门账号登录
export async function subLogin({ username, password }: any) {
  return request(`/api/bui/sub/sub/login`, {
    method: 'POST',
    data: {
      mobile: username,
      login_pwd: password
    }
  });
}
